home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Mark Pilgrim / Jotto ][ 1.2 / source / Wipes ƒ / Circle in.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-30  |  1.9 KB  |  72 lines  |  [TEXT/MMCC]

  1. #include "timing.h"
  2.  
  3. #define    gap            4        /* difference between one radius and the next */
  4. #define CorrectTime 2
  5. #define theWindowHeight (boundsRect.bottom-boundsRect.top)
  6. #define theWindowWidth (boundsRect.right-boundsRect.left)
  7.  
  8. pascal short CircleIn(GrafPtr sourceGrafPtr, GrafPtr destGrafPtr, Rect boundsRect);
  9.  
  10. /* Take a really big circle, then a slightly smaller circle (-gap), then
  11.    take the region in between them and copy that, then decrease the outer
  12.    circle radius by gap.  Thus: circle in, by successive donut-like copies. */
  13.  
  14. pascal short CircleIn(GrafPtr sourceGrafPtr, GrafPtr destGrafPtr, Rect boundsRect)
  15. {
  16.     Rect            theRect;
  17.     short            cx, cy;
  18.     RgnHandle        curregion,lastregion,diffregion;
  19.     Point            zeroPoint;
  20.     short            StartRadius;
  21.     
  22.     zeroPoint.h=boundsRect.left;
  23.     zeroPoint.v=boundsRect.top;
  24.  
  25.     cx = theWindowWidth / 2;
  26.     cy = theWindowHeight / 2;
  27.     
  28.     lastregion=NewRgn();
  29.     StartRadius=0;
  30.     do
  31.     {
  32.         StartRadius+=2*gap;
  33.         theRect.left=cx-StartRadius;     /* circumscribing rectangle for outer circle */
  34.         theRect.right=cx+StartRadius;
  35.         theRect.top=cy-StartRadius;
  36.         theRect.bottom=cy+StartRadius;
  37.         OffsetRect(&theRect, boundsRect.left, boundsRect.top);
  38.         SetEmptyRgn(lastregion);
  39.         OpenRgn();
  40.             FrameOval(&theRect);        /* first circle */
  41.         CloseRgn(lastregion);
  42.     }
  43.     while (!PtInRgn(zeroPoint, lastregion));
  44.     
  45.     curregion=NewRgn();
  46.     diffregion=NewRgn();
  47.  
  48.     while (theRect.right-theRect.left>0)
  49.     {
  50.         StartTiming();
  51.         theRect.left+=gap;
  52.         theRect.right-=gap;
  53.         theRect.top+=gap;
  54.         theRect.bottom-=gap;
  55.         SetEmptyRgn(curregion);
  56.         OpenRgn();
  57.             FrameOval(&theRect);   /* inner circle */
  58.         CloseRgn(curregion);
  59.         DiffRgn(lastregion,curregion,diffregion);   /* donut we need */
  60.         CopyBits(&(sourceGrafPtr->portBits), &(destGrafPtr->portBits),
  61.                 &boundsRect, &boundsRect, 0, diffregion);
  62.         CopyRgn(curregion,lastregion);    /* outer circle = inner circle */
  63.         TimeCorrection(CorrectTime);
  64.     }
  65.     
  66.     DisposeRgn(curregion);
  67.     DisposeRgn(lastregion);
  68.     DisposeRgn(diffregion);
  69.     
  70.     return 0;
  71. }
  72.